<?php
error_reporting(0);
if (isset($from_page)) {
	$params[sid] = $sid;
	$params[action] = "home";
	$url = "$baseURL/?".encode_params($params);
	echo "<div style='padding: 4 4 4 4; text-align:right;'><a href='$url'>&laquo; Back to Home</a><br></div>";
}
?>
<script type='text/javascript' src='validation.js'></script>
<script>
var seriousCondition = 0;

function round(number,X) {
	X = (!X ? 2 : X);
	return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}

function calc(type,id,realp,domainp,forceCalculation){
	realp = parseFloat(realp);
	domainp = parseFloat(domainp);
	el1 = document.getElementById(id+'1');
	el2 = document.getElementById(id+'2');
	el3 = document.getElementById(id+'3');
	el4 = document.getElementById(id+'4');
	el5 = document.getElementById(id+'5');

	el0 = document.getElementById('settings[' + id + '][plan_price]');

	if(type=='1'){
		if (forceCalculation) el2.value = display_dec_string(round(el1.value*12,2));
		else el2.value = display_dec_string(round(el0.value));
		//el3.value = display_dec_string(round(((el1.value*12)+domainp)/12,2));
		//el4.value = display_dec_string(round((el1.value*12)+domainp,2));
		el3.value = (el3.disabled) ? "fd n/a" : display_dec_string(round(((el1.value*12)+domainp)/12,2));
		el4.value = (el4.disabled) ? "fd n/a" : display_dec_string(round((el1.value*12)+domainp,2));
	}
	if(type=='2'){
		el1.value = display_dec_string(round(el2.value/12,2));
		//el3.value = display_dec_string(round((el2.value+domainp)/12,2));
		//el4.value = display_dec_string(round(el2.value+domainp,2));
		el3.value = (el3.disabled) ? "fd n/a" : display_dec_string(round((el2.value+domainp)/12,2));
		el4.value = (el4.disabled) ? "fd n/a" : display_dec_string(round(el2.value+domainp,2));
	}
	if(type=='3'){
		el1.value = display_dec_string(round((el3.value-(domainp/12)),2));
		if (forceCalculation) el2.value = display_dec_string(round(((el3.value*12)-domainp),2));
		else el2.value = display_dec_string(round(el0.value));
		//el4.value = display_dec_string(round((el3.value*12),2));
		el4.value = (el4.disabled) ? "fd n/a" : display_dec_string(round((el3.value*12),2));
	}
	if(type=='4'){
		el1.value = display_dec_string(round(((el4.value-domainp)/12),2));
		if (forceCalculation) el2.value = display_dec_string(round((el4.value-domainp),2));
		else el2.value = display_dec_string(round(el0.value));
		//el3.value = display_dec_string(round(((el1.value*12)+domainp)/12,2));
		el3.value = (el3.disabled) ? "fd n/a" : display_dec_string(round(((el1.value*12)+domainp)/12,2));
	}

	el5.value = display_dec_string(round(el2.value - realp,2));
}

function display_dec_string(input) {
	var ost = 0;
	var cch = 0;
	var result;
	cch = Math.floor(input);
	if( cch == 0 ) {
		ost = input;
	} else {
		ost = input % cch;
	}
	ost = Math.round(ost * 100);
	if ( ost < 10 ) ost = "0" + ost;
	result = cch + "." + ost;
	if (result == "NaN.NaN") result ='';
	return result;
}

function triggerCalc (calcID) {
	var ti1 = document.getElementById("settings[" + calcID + "][plan_price]");
	var ti2 = document.getElementById(calcID + "1");
	ti2.value = display_dec_string(parseFloat(ti1.value)/12);

}

function ch_calc(calcID, wholeSale, domainP){
	triggerCalc (calcID);
	calc('1',calcID, wholeSale, domainP);
	el = document.getElementById(calcID);
	el1 = document.getElementById(calcID+"_");
	if(el.style.display=='none'){
		el.style.display = 'inline';
		el1.style.display = 'none';
	}
	else {
		el.style.display = 'none';
		el1.style.display = 'inline';
	}
}
function set_price(id, wholeSale, domainP){
	if (seriousCondition) {
		seriousCondition++;
		return;
	}
	el2 = document.getElementById(id+'2');
	el = document.getElementById('settings['+id+'][plan_price]');
	el.value = el2.value;
	if (checkPrice(el, id, wholeSale, domainP)) ch_calc(id, wholeSale, domainP);
	else calc('1',id, wholeSale, domainP);
	//ch_calc(id);
}

function checkPrice (obj, id, wholeSale, domainP) {
    var maxPObj, minPObj, objTitle, objValue, errMsg = "", defValueObj;
    objTitle = obj.title;
    objValue = parseFloat(obj.value);
    //alert(obj.type);
    if (typeof(objTitle) == 'undefined') return false;
    var pattern = /^bp_pp_(\d+)$/;
    var matches = objTitle.match(pattern);
    if (matches == null) return false;
    if (!(maxPObj = document.getElementById('bp_maxp_' + matches[1]))) return false;
    if (!(minPObj = document.getElementById('bp_minp_' + matches[1]))) return false;
    if (!(defValueObj = document.getElementById('def_price_' + matches[1]))) return false;
    if (objValue == parseFloat(defValueObj.value)) return true;
    /*
	if (objValue < parseFloat(minPObj.value)) {
         errMsg = "Retail price for this plan must not be lower than minimum price!";
    }
    if (objValue > parseFloat(maxPObj.value)) {
         errMsg = "Retail price for this plan must not be higher than maximum price!";
    }
	*/
	if (objValue < parseFloat(minPObj.value) || objValue > parseFloat(maxPObj.value)) {
		errMsg = "12-month retail price for this plan must NOT be lower than $" + minPObj.value + " or higher than $" + maxPObj.value + "!\n"
		+ "1-month retail price for this plan must NOT be lower than $" + display_dec_string(minPObj.value/12) + " or higher than $" + display_dec_string(maxPObj.value/12) + "!"
		+ "\nThose prices were automatically reset to their initial values.";
	}
    if (errMsg != "") {

	 	 obj.value=defValueObj.value;
		 triggerCalc (id);
		 calc('1',id, wholeSale, domainP);
         obj.focus();
		 seriousCondition++;
		 alert(errMsg);
		 if (seriousCondition == 2) {

		 	seriousCondition = 0;
			set_price(id, wholeSale, domainP);
		}
		seriousCondition = 0;
		return false;
    }
	return true;
}

var myWin = '';

function openWin(url, name, properties) {
    if (myWin && myWin.open && !myWin.closed) {
        myWin.close();
    }
    myWin = window.open(url, name, properties);
    return false;
}

function ctrlPriceInput (obj) {
	var tmpObj;
	var value = obj.value;
	var newValue = '';
	/*
	if (!/\d/.test(value.charAt(value.length-1))) {
		if (value.charAt(value.length-1) == ',') obj.value = value.substr(0, value.length-1) + ".";
		else obj.value = value.substr(0, value.length-1);
	}

	return true;
	*/

	var pointCnt = true;
	for (var i=0; i<value.length; i++) {
		if (/\d/.test(value.charAt(i))) {
			newValue += value.charAt(i);
		} else {
			if (pointCnt && (value.charAt(i) == "." || value.charAt(i) == ",")) {
				newValue += ".";
				pointCnt = false;
			}
		}
	}
	var pArr = newValue.split(".");
	if (pArr && pArr.length && pArr.length > 1) {
		newValue = pArr[0] + '.' + pArr[1].substr(0,2);
	}
	obj.value = newValue;
}


function validatePrices (formObj) {

	var errMsg ='', formEl, planPrice, planID, planName, minPrice, maxPrice, tmpObjs = new Array();

	for (var i=0; i < formObj.length; i++) {
		formEl = formObj.elements[i];
		if (formEl.type == 'text' && typeof(formEl.title) != 'undefined' && formEl.title.indexOf('bp_pp_') == 0) {

			// get price
			planPrice = parseFloat(formEl.value);

			// get plan name
			tmpObjs[0] = formEl.name.split("["); //='settings[Business][plan_price]'
			if (typeof(tmpObjs[0][1]) != 'undefined') {
				tmpObjs[1] = tmpObjs[0][1].split("]");
				if (typeof(tmpObjs[1][1]) != 'undefined') {
					planName = tmpObjs[1][0];
				}
			}

			// get plan id
			tmpObjs[0] = formEl.title.split("_");
			if (typeof(tmpObjs[0][2]) != 'undefined') {
				planID = tmpObjs[0][2];
			}

			// get min and max price
			tmpObjs[0] = document.getElementById('bp_minp_' + planID);
			tmpObjs[1] = document.getElementById('bp_maxp_' + planID);
			if (tmpObjs[0] && tmpObjs[1]) {
				minPrice = parseFloat(tmpObjs[0].value);
				maxPrice = parseFloat(tmpObjs[1].value);
				tmpObjs[2] = document.getElementById('real_price_' + planID);
				tmpObjs[3] = document.getElementById('domain_price_' + planID);
				if (!isNaN(planPrice) && !isNaN(minPrice) && !isNaN(maxPrice)) {
					if (planPrice > maxPrice) {
						errMsg += ' - 12-month retail price for plan ' + planName + ' must NOT be higher than $' + maxPrice + '\n';
						formEl.value  = formEl.defaultValue;
						if (tmpObjs[2] && tmpObjs[3]) {
							triggerCalc(planName);
							calc("1", planName, tmpObjs[2].value, tmpObjs[3].value);
						}
					}
					if (planPrice < minPrice) {
						errMsg += ' - 12-month retail price for plan ' + planName + ' must NOT be lower than $' + minPrice + '\n';
						formEl.value  = formEl.defaultValue;
						if (tmpObjs[2] && tmpObjs[3]) {
							triggerCalc(planName);
							calc("1", planName, tmpObjs[2].value, tmpObjs[3].value);
						}
					}
				}
			}

		}

		// domains only
		if (formEl.type == 'text' && typeof(formEl.name) != 'undefined' && formEl.name.indexOf('domain_price') == 0) {
			tmpObjs[0] = document.getElementById('domain_price_min');
			tmpObjs[1] = document.getElementById('domain_price_max');
			var domain_price = parseFloat(formEl.value);
			var domain_price_min = parseFloat(tmpObjs[0].value);
			var domain_price_max = parseFloat(tmpObjs[1].value);

			if (!isNaN(domain_price) && !isNaN(domain_price_min) && !isNaN(domain_price_max)) {

				if (domain_price < domain_price_min) {
					errMsg += ' - domain price must NOT be lower than $' + domain_price_min + "\n";
					formEl.value = formEl.defaultValue;
				}
				if (domain_price > domain_price_max) {
					errMsg += ' - domain price must NOT be higher than $' + domain_price_max + "\n";
					formEl.value = formEl.defaultValue;
				}

			}

		}

	}



	if (errMsg != '') {
		errMsg = 'The following prices are outside allowed values:\n' + errMsg + '\nThose prices were automatically reset to their initial values.';
		alert(errMsg);
		return false;
	}
	return true;
}

</script>
<?
$params[sid] = $sid;
$params[action] = "comparePlans";
$compareurl = "$baseURL/?".encode_params($params);
$compare_msg = translate('click_here_popup_features',array('url' => "$compareurl"));
?>
<div align="left"><b><?php echo translate('edit_products');?></b><br>
  <br>
  <font class="text"><?=$compare_msg;?><br>
  <br>
  <?php echo translate('click_here_setup_ex');?>


  </font></div>
<br>
  <?
	$params[sid] = $sid;
	$params[action] = "editPlans";
	if (isset($from_page)) {
		$params['from_page'] = $from_page;
	}
	$url = "$baseURL/?".encode_params($params);
	//$errorMsg = "";
	#$plans = list_reseller_plans($id,'array');
	//////// rp2 patch
	#if (is_me()) {
		include('wallet_db.html');
  //$dberror = translate('int_error');
		unset($plans);

		//------------------------------------------------------
		        $sql['type']='SELECT';
		        $sql['params']='currency,products';
		        $sql['table']='stores';
		        $sql['where']="reseller_id='$id'";
		        $sql['options']='';
		        $sql['return']='struct';
	        //------------------------------------------------------
//		print_r($sql);
        	if (!$result=sql_exec($sql,$dbh81,'assoc')) {
	                $errorMsg = translate('int_error');
									include_once('errorMsg.html');
									exit;
		}
		$res_currency=$result[0][currency];
		$res_products=$result[0][products];
		if (isset($_POST[form_sent]) && $_POST[form_sent]=='yes') {
			//------------------------------------------------------
                        	$sql['type']='SELECT';
                        	$sql['params']='name';
                        	$sql['table']='products';
                        	$sql['where']="reseller_id='$id' AND type='plan'";
                        	$sql['options']='';
                        	$sql['return']='struct';
                	//------------------------------------------------------
			if (!$result=sql_exec($sql,$dbh81,'assoc')) {
	                $errorMsg = translate('int_error');
									include_once('errorMsg.html');
									exit;
			}
			foreach ($result as  $res) {
				$pl[]=$res[name];
			}
			foreach ($pl as $vl) {
				//------------------------------------------------------
                        		$sql['type']='SELECT';
                        		$sql['params']='product_id, price, max_price, min_price';
                        		$sql['table']='products';
                        		$sql['where']="reseller_id='$id' AND type='plan' AND name='$vl'";
                        		$sql['options']='';
                        		$sql['return']='struct';
                		//------------------------------------------------------
				if (!$result=sql_exec($sql,$dbh81,'assoc')) {
	                		$errorMsg = translate('int_error');
					include_once('errorMsg.html');
					exit;
				}
				$price=$result[0];

                                $p_price = sprintf("%01.2f", $_POST['settings'][$vl]['plan_price']);
                                $min_price = sprintf("%01.2f", $price['min_price'][12][$res_currency]);
                                $max_price = sprintf("%01.2f", $price['max_price'][12][$res_currency]);

				if ($p_price > $max_price) {

					$errorMsg = translate('invalid_plan_max_price' , array('plan_max' => $max_price , 'k' => $vl));
                                        include_once('errorMsg.html');
					$error_occured[($result[0]['product_id'])] = 1;
                                        continue;
                                }
                                if ($p_price < $min_price) {

					$errorMsg = translate('invalid_plan_min_price' , array('plan_min' => $min_price , 'k' => $vl));
                                        include_once('errorMsg.html');
					$error_occured[($result[0]['product_id'])] = 1;
                                        continue;

                                }


				$price[price][12][$res_currency]=$_POST[settings][$vl][plan_price];
				$price=base64_encode(serialize($price[price]));
				$sql="UPDATE products SET price='$price'
					WHERE reseller_id='$id' AND type='plan' AND name='$vl'";
				if (!$result=pg_query($dbh81,$sql)) {
	                $errorMsg = translate('int_error');
									include_once('errorMsg.html');
									exit;
				}
				unset($result);
				unset($sql);
			}

			//------------------------------------------------------
				$sql['type']='SELECT';
				$sql['params']='price';
				$sql['table']='products';
				$sql['where']="reseller_id='$id' AND type='domain'";
				$sql['options']='';
				$sql['return']='struct';
			//------------------------------------------------------
			if (!$result=sql_exec($sql,$dbh81,'assoc')) {
	                $errorMsg = translate('int_error');
									include_once('errorMsg.html');
									exit;
			}
			$price=$result[0];
			$price[price][12][$res_currency]=$_POST[domain_price];
			$price=base64_encode(serialize($price[price]));
			$sql="UPDATE products SET price='$price' WHERE reseller_id='$id' AND type='domain'";
			if (!$result=pg_query($dbh81,$sql)) {
	                $errorMsg = translate('int_error');
									include_once('errorMsg.html');
									exit;
			}

			if(!$error_occured) {
			$okMsg = translate('successfully_modified_settings');
			include_once('okMsg.html');
			}
			unset($sql);
		}


		//------------------------------------------------------
		//        $sql['type']='SELECT';
		//        $sql['params']='count(product_id) AS count';
		//        $sql['table']='products';
		//        $sql['where']="reseller_id='$id' and type='plan'";
		//        $sql['options']='';
		//       $sql['return']='struct';
    //------------------------------------------------------
   	//if (!$result=sql_exec($sql,$dbh81,'assoc')) {
    //        exit("<br><div class=errormsg>$dberror</div><br>");
		//}
		//$pl_count=$result[0][count];
		//------------------------------------------------------
		        $sql['type']='SELECT';
		        $sql['params']='*';
		        $sql['table']='products';
		        $sql['where']="reseller_id='$id' and type='domain'";
		        $sql['options']='';
		        $sql['return']='struct';
	        //------------------------------------------------------
        	if (!$domain=sql_exec($sql,$dbh81,'assoc')) {
	                $errorMsg = translate('int_error');
									include_once('errorMsg.html');
									exit;
		}
		$domain=$domain[0];
		//------------------------------------------------------
		        $sql['type']='SELECT';
		        $sql['params']='*';
		        $sql['table']='products';
		        $sql['where']="reseller_id='$id' AND type='plan'";
		        $sql['options']='ORDER BY name';
		        $sql['return']='struct';
	        //------------------------------------------------------
        	if (!$result=sql_exec($sql,$dbh81,'assoc')) {
	                $errorMsg = translate('int_error');
									include_once('errorMsg.html');
									exit;
	        }
		$i=0;
		foreach ($result as $res) {
			$plans[$i]['product_id'] = $res['product_id'];
			if ($res_products[domains_free][$res[product_id]][12]=='on') {
				$plans[$i][has_domain]='inplan';
			} else {
				if ($res[services][register_domain]==1) {
					$plans[$i][has_domain]='true';
				} else {
					$plans[$i][has_domain]='false';
				}
			}

			$plans[$i][domain_price]=sprintf("%01.2f",$domain[price][12][$res_currency]);
			$plans[$i][plan_price]=sprintf("%01.2f",$res[price][12][$res_currency]);

			if ($res_products[plans_on_index][$res[product_id]]=='on') {
				$plans[$i][display_on_index]='true';
			} else {
				$plans[$i][display_on_index]='false';
			}

			if ($res_products[plans_offering][$res[product_id]]=='on') {
				$plans[$i][offering]='true';
			} else {
				$plans[$i][offering]='false';
			}

			$plans[$i][plan]=$res[name];

			$disk_space=$res[services][disk_space]/1024;
			$disk_space.=" MB Hosting| ";
			$traffic=$res[services][traffic]/1024000;
			$traffic.=" GB Transfer| ";
			#if ($res[services][support]==1) {
			#	$support='24/7 phone support| ';
			#}
			$domains = $res['services']['domain'];
			if ($domains == 1) {
				$domains .= ' Domain hosted|';
			} else {
				$domains .= ' Domains hosted|';
			}
			$plans[$i][description]=$disk_space.$traffic.$domains;
			$plans[$i][setup_fee]='0.00';
			$plans[$i][setup_fee_max]='0.00';
			$plans[$i][plan_min_price]=sprintf("%01.2f",$res[min_price][12][$res_currency]);
			$plans[$i][plan_real_price]=sprintf("%01.2f",$res[wholesale][12][$res_currency]);
			$plans[$i][plan_max_price]=sprintf("%01.2f",$res[max_price][12][$res_currency]);
			$plans[$i][domain_min_price]=sprintf("%01.2f",$domain[min_price][12][$res_currency]);
			$plans[$i][domain_real_price]=sprintf("%01.2f",$domain[wholesale][12][$res_currency]);
			$plans[$i][domain_max_price]=sprintf("%01.2f",$domain[max_price][12][$res_currency]);
		$i++;
		}
		#exit(print_r($plans));

	$params[sid] = $sid;
	$params[action] = "createPlan";
	$urla = "$baseURL/?".encode_params($params);

	#if ($pl_count<4) {
	#	echo "<p>You have $pl_count plans in your store. Create new one <a href='$urla'>here</a>!</a>";
	#} else {
	#	echo "<p>You have $pl_count plans in your store. You can not create more plans!</a>";
	#}
	#}
	//////////////////////////
	if(is_array($plans)){
		echo "<form action='$url' method='POST' onSubmit='return validatePrices(this)'>";
		foreach($plans as $plan){
			if($id=='975' || $id=='2338'){
				$plan[plan_real_price] = $plan[plan_real_price]-($plan[plan_real_price]/10);
			}

			switch($plan[has_domain]){
				case "true": $plan[has_domain_sel][1]='selected'; break;
				case "false": $plan[has_domain_sel][2]='selected'; break;
				case "inplan": $plan[has_domain_sel][3]='selected'; break;
				default: $plan[has_domain_sel][2]='selected'; break;
			}

			$plan[domain_profit] = $plan[domain_price]-$plan[domain_real_price];
			$plan[domain_profit] = sprintf("%01.2f",$plan[domain_profit]);
			if($plan[domain_profit] <= 0) $plan[domain_profit]=0;

			if($plan[plan_price]=='') $plan[plan_yn2]='selected';
			else $plan[plan_yn1]='selected';
			$plan[plan_profit] = $plan[plan_price]-$plan[plan_real_price];
			$plan[plan_profit] = sprintf("%01.2f",$plan[plan_profit]);
			if($plan[plan_profit] <= 0) $plan[plan_profit]=0;

			if(!$plan[setup_fee]) $plan[setup_fee]=0;
			if(!$plan[domain_price]) $plan[domain_price]=0;
			if(!$plan[plan_price]) $plan[plan_price]=0;

			//tova e domainite ako ne se predlagat zna4i nemoget da se slagat i ceni :)
			$disable_calc[$plan[plan]][0] = 'disabled';
			if($plan[has_domain]=='inplan'){
		        $disable_calc[$plan[plan]][1] = 'disabled';
	       		$disable_calc[$plan[plan]][0] = '';
			}
			if($plan[has_domain]=='false' || $plan[has_domain]=='inplan'){
				$disabled_color = " bgcolor='#E5E4E4' ";
				$disable_input = " DISABLED ";
				//$plan[domain_price] = '0';
				$plan[domain_profit] = '0';
				$hidden_has_domain = "<input type='hidden' name='domain_price' value='$plan[domain_price]'>";

			}


			$plan[description] = implode(",",array_slice(explode("|",$plan[description]),0,3));

			if(!$domain_list)
			$domain_list = "
			<TABLE border=0 class='bTable' cellspacing='0' width='560'>
				<tr>
					<th nowrap>" . translate('desc') . "</th>
					<th nowrap>" . translate('retail_price') . " [<a href='#' onClick=\"show_help('help.html#domain_retail_price')\">?</a>]</th>
					<th nowrap>" . translate('min_price') . " [<a href='#' onClick=\"show_help('help.html#domain_min_price')\">?</a>]</th>
					<th nowrap>" . translate('max_price') . " [<a href='#' onClick=\"show_help('help.html#domain_max_price')\">?</a>]</th>
					<th nowrap>" . translate('wholesale') . " [<a href='#' onClick=\"show_help('help.html#domain_wholesale')\">?</a>]</th>
 					<th nowrap>" . translate('profit') . " [<a href='#' onClick=\"show_help('help.html#domain_profit')\">?</a>]</th>
				</tr>
				<tr $disabled_color >
					<td>" . translate('dom_price') . "</td>
					<td>
					$hidden_has_domain
						\$ <input $disable_input type='text' onKeyUp='ctrlPriceInput(this)' name='domain_price' size='4' value='$plan[domain_price]'></td>
					<td>\$ $plan[domain_min_price] <input type='hidden' id='domain_price_min'  value='$plan[domain_min_price]'></td>
					<td>\$ $plan[domain_max_price] <input type='hidden' id='domain_price_max'  value='$plan[domain_max_price]'></td>
					<td>\$ $plan[domain_real_price]</td>
					<td>\$ $plan[domain_profit]</td>
				</tr>

			</TABLE><br>";

	                unset($params);
        	        $params[sid] = $sid;
        	        $params[action] = "showPlanDetails";
	               	$params[pid] = $plan['product_id'];
	                $params[rid] = $id;
	                $showurl = "$baseURL/?".encode_params($params);

			$redborder = '';
			$imgerror = '';

			if (in_array($plan['product_id'],array_keys($error_occured))) {
				// draw red border for the fckd up plan
				$redborder = 'style="border-color: red;"';
				$imgerror = '<img align=\'right\' border=\'0\'src=\'images/attention.gif\'>';
			}

                        global $errorMsg;
                          if (isset($errorMsg) && $errorMsg != '')
                                include_once('errorMsg.html');
                          if (isset($okMsg) && $okMsg != '')
                                include_once('okMsg.html');

			$list .="
			<TABLE border='0' class='bTable' cellspacing='0' width='560' $redborder>
				<tr>
					<!-- <td><input type='checkbox' name='settings[$plan[plan]][display_on_index]' value='true' $ch> Display on the index page?</td> -->
					<!---td>$plan[plan] plan:</td--->
                                        <!---td><a href=''>$plan[plan]</a>plan:</td--->
					<td>
					<a href='#' onClick=\"return openWin('$showurl','PlanDetails','width=650, height=650, scrollbars=yes'); return false;\">$plan[plan] plan</a> :
					</td>
					<td colspan='10'>$imgerror$plan[description]</td>
				</tr>
				<tr>
					<th nowrap>" . translate('desc') . "</th>
					<th nowrap>" . translate('retail_price') . " [<a href='#' onClick=\"show_help('help.html#retail_price');return false;\">?</a>]</th>
					<th nowrap>" . translate('min_price') . " [<a href='#' onClick=\"show_help('help.html#min_price'); return false;\">?</a>]</th>
					<th nowrap>" . translate('max_price') . " [<a href='#' onClick=\"show_help('help.html#max_price'); return false;\">?</a>]</th>
					<th nowrap>" . translate('wholesale') . " [<a href='#' onClick=\"show_help('help.html#wholesale'); return false;\">?</a>]</th>
    					<th nowrap>" . translate('profit') . "[<a href='#' onClick=\"show_help('help.html#profit'); return false;\">?</a>]</th>
				</tr>
<!---
				<tr>
					<td>Setup fee</td>
					<td>$<input type='text' name='settings[$plan[plan]][setup_fee]' size='4' value='$plan[setup_fee]'>(one time fee)</td>
					<td>$0</td>
					<td>$plan[setup_fee_max]</td>
					<td>N/A</td>
					<td>\$ $plan[setup_fee]</td>
				</tr>
--->
				<tr>
					<td>" . translate('12m_price') . "</td>
					<td>\$ <input type='text' id='settings[$plan[plan]][plan_price]'  title='bp_pp_".$plan[product_id]."'  name='settings[$plan[plan]][plan_price]' size='4' value='$plan[plan_price]' onBlur='ctrlPriceInput(this); return true; checkPrice(this, \"".$plan[plan]."\", \"".$plan[plan_real_price]."\",\"".$plan[domain_price]."\");' onKeyUp='ctrlPriceInput(this);triggerCalc(\"".$plan[plan]."\");calc(\"1\",\"".$plan[plan]."\",\"".$plan[plan_real_price]."\",\"".$plan[domain_price]."\");'> <input id='def_price_".$plan[product_id]."' value='".$plan[plan_price]."' type='hidden' ><input id='real_price_".$plan[product_id]."' value='".$plan[plan_real_price]."' type='hidden' ><input id='domain_price_".$plan[product_id]."' value='".$plan[domain_price]."' type='hidden' ></td>
					<td>\$ $plan[plan_min_price] <input id='bp_minp_".$plan['product_id']."' value='".$plan[plan_min_price]."' type='hidden'></td>
					<td>\$ $plan[plan_max_price] <input id='bp_maxp_".$plan['product_id']."' value='".$plan[plan_max_price]."' type='hidden'></td>
					<td>\$ $plan[plan_real_price]</td>
					<td>\$ $plan[plan_profit]</td>
				</tr>
	<tr>
		<td colspan='6'>
			<div id='$plan[plan]_'><a href='#' onClick=\"ch_calc('$plan[plan]', '$plan[plan_real_price]','$plan[domain_price]'); return false;\">$plan[plan] " . translate('plan_calc') . "</a></div>
			<div id='$plan[plan]' style='display:none'>
					<table width='100%' border='0' class='bTable' cellspacing='0' align='center'>
						<tr>
								<th  class='text'>" . translate('1m_price') . "</th>
								<th  class='text'>\$<input type='text' size='6' id='$plan[plan]1' onKeyUp=\"ctrlPriceInput(this);calc('1','$plan[plan]','$plan[plan_real_price]','$plan[domain_price]', 1);\" onBlur=\"ctrlPriceInput(this);calc('1','$plan[plan]','$plan[plan_real_price]','$plan[domain_price]', 1);\" ".$disable_calc[$plan[plan]][1]."></th>
								<th  class='text'>" . translate('retail_price') . "</th>
								<th  class='text'>\$<input type='text' size='6' id='$plan[plan]2' onkeyup=\"ctrlPriceInput(this);calc('2','$plan[plan]','$plan[plan_real_price]','$plan[domain_price]', 1);\" onblur=\"ctrlPriceInput(this);calc('2','$plan[plan]','$plan[plan_real_price]','$plan[domain_price]', 1);\" ".$disable_calc[$plan[plan]][1]."></th>
						</tr>
						<tr>
								<th  class='text'>" . translate('1m_price'). " + ". translate('free_domain') . "</th>
								<th  class='text'>\$<input type='text' size='6' id='$plan[plan]3' onkeyup=\"ctrlPriceInput(this);calc('3','$plan[plan]','$plan[plan_real_price]','$plan[domain_price]', 1);\" onblur=\"ctrlPriceInput(this);calc('3','$plan[plan]','$plan[plan_real_price]','$plan[domain_price]', 1);\" ".$disable_calc[$plan[plan]][0]."></th>
								<th  class='text'>" . translate('retail_price') . " + " . translate('free_domain') . "</th>
								<th  class='text'>\$<input type='text' size='6' id='$plan[plan]4' onkeyup=\"calc('4','$plan[plan]','$plan[plan_real_price]','$plan[domain_price]', 1);\" onblur=\"calc('4','$plan[plan]','$plan[plan_real_price]','$plan[domain_price]', 1);\" ".$disable_calc[$plan[plan]][0]."></th>
						</tr>
						<tr>
								<th  class='text'>" . translate('plan_profit') . "</th>
								<th  class='text'>\$<input type='text' size='6' id='$plan[plan]5' disabled></th>
								<th  class='text' colspan='2' align='center'>
									<input type='button' value='Set this price'  onClick=\"set_price('$plan[plan]','$plan[plan_real_price]','$plan[domain_price]');\">
									<input type='button' value='Close' onClick=\"ch_calc('$plan[plan]', '$plan[plan_real_price]','$plan[domain_price]');\">
								</th>
						</tr>
					</table>
			</div>
		</td>
	</tr>

			</TABLE><br><br>";
		}

		echo $list;
		echo "<br>";
		echo $domain_list;
		echo "<BR>
			<TABLE border=0 class='bTable' cellspacing='0'>
				<TR>
					<TD>
						<input type='button' value='" . translate('back') . "'  onClick='javascript:history.go(-1)'>
					</TD>
					<TD>
						<input type='submit' value='" . translate('save') . "'>
						<input type=hidden name=form_sent value='yes'>
					</TD>
				</TR>
			</TABLE>
		";
		echo "</form>";
	}else{
		echo "<BR>
			<TABLE border=0 class='bTable' cellspacing='0'>
				<TR>
					<TD>
					" . translate('we_sorry') . "
					</TD>
				</TR>
			</TABLE>
		";
	}
?>
